package org.noranj.dao;

import java.util.List;

import org.noranj.dto.ConversationDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;

import com.sun.xml.txw2.annotation.XmlElement;


@Service
public class ConversationDAOImpl implements ConversationDAO {

  
  @Autowired
  private SessionFactory sessionFactory;
  
  
  public void insertConversation(ConversationDTO conversation) {
	  sessionFactory.getCurrentSession().save(conversation);
  }

  public ConversationDTO getConversation(int userId) {
	  return (ConversationDTO)sessionFactory.getCurrentSession().get(ConversationDTO.class, userId); 
  }
  
   
  public List<ConversationDTO> getConversations() {
    Criteria criteria= sessionFactory.getCurrentSession().createCriteria(ConversationDTO.class);
    return  criteria.list();
  }

}
